package com.xiu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xiu.mapper.ExamGradeMapper;
import com.xiu.mapper.ExamSubjectMapper;
import com.xiu.mapper.ExamTiMapper;
import com.xiu.pojo.ExamGrade;
import com.xiu.pojo.ExamSubject;
import com.xiu.pojo.ExamTi;

@Service
public class StudentService {
	
	@Autowired
	ExamSubjectMapper examSubjectMapper;
	
	@Autowired
	ExamGradeMapper examGradeMapper;
	
	@Autowired
	ExamTiMapper examTiMapper;
	
	//学生查看所有科目
	public List<ExamSubject> stuFindSubjects(int examStuId){
		return examSubjectMapper.stuFindSubjects(examStuId);
	}
	
	//查看该科成绩
	public List<ExamGrade> stuFindGrade(int examSubjectId){
		return examGradeMapper.findStuGrade(examSubjectId);
	}
	
	//学生查看全部成绩
	public List<ExamGrade> stuShowGrade(int examStuId){
		return examGradeMapper.showGrade(examStuId);
	}
	
	//学生考试，通过科目Id找到题目
	public List<ExamTi> stuExam(int examSubjectId){
		return examTiMapper.findTiById(examSubjectId);
	}
	
	public ExamTi findKey(int examSubjectId){
		return examTiMapper.findTiById1(examSubjectId);
	}
	
	//学生考试，通过科目Id找到考试总时长
	public ExamSubject stuExamTime(int examSubjectId){
		return examSubjectMapper.selectByPrimaryKey(examSubjectId);
	}
	
	//修改成绩
	public int editGrade(ExamGrade examGrade){
		return examGradeMapper.updateByPrimaryKeySelective(examGrade);
	}
	
	
	public ExamSubject findDone(int examStuId){
		return examSubjectMapper.findDone(examStuId);
	}
	//xiugaichengji
	/*public ExamGrade upadeGrade(ExamGrade examGrade){
		return examGradeMapper.updateGrade(examGrade);
	}*/
	
	public int editSubject(ExamSubject examSubject){
		return examSubjectMapper.updateByPrimaryKeySelective(examSubject);
	}
	
	/*public ExamGrade findGrade(int examSubjectId){
		return examGradeMapper.findGradeId(examSubjectId);
	}*/
	
	public int addGrade(ExamGrade examGrade){
		return examGradeMapper.insertSelective(examGrade);
	}
}
